package com.cx.mall.demo.controller;

import com.cx.mall.demo.entity.Children;
import com.cx.mall.demo.entity.Dog;
import com.cx.mall.demo.entity.Person;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PersonController { //personController
//    @Autowired  // 注解：从容器中取Person对象
//    @Qualifier("p")
    @Resource(name = "p")
    private Person person;
    @Autowired  // 依赖注入
    private Dog dog;
    @Autowired
    private Children children;
    @GetMapping("/person") // 映射URI
    public String getPerson(){
        return person.toString();
    }
    @GetMapping("/dog")
    public String getDog(){
        dog.setName("旺财");
        return dog.toString();
    }
    @GetMapping("/children")
    public String getChildren(){
        children.setName("小红");
        return children.toString();
    }
}
